﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sprout.Core.Extensions
{
    /// <summary>
    /// 字符串扩展
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// 转换字符串
        /// 空则返回空字符串
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string ToEmpty(this string value)
        {
            return value == null ? string.Empty : value;
        }
        /// <summary>
        /// 转换字符串并删除左右空格
        /// 空则返回空字符串
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string ToEmptyAndTrim(this string value)
        {
            if (value == null)
            {
                return string.Empty;
            }
            return value.Trim();
        }
    }
}
